Ext.onReady(function(){


    //Ext.get('domainlocationform').style.visibility = 'visible';
    //Ext.get('progressbar').style.visibility = 'hidden';
    // initialize the cookie provider
   //  var cp = new Ext.state.CookieProvider({
   //         path: "/cgi-bin/",
   //         expires: new Date(new Date().getTime()+(1000*60*60*24*30)), //30 days
   //         domain: "extjs.com"
   //     });
   // 
   // Ext.state.Manager.setProvider(cp);


   // now get the values from the cookies
   var domainName = getCookie("domainName");
   var domainDocsLocation = getCookie("domainDocsLocation");

   if(domainName == null) 
        domainName = "MyDomain";
   if(domainDocsLocation == null) 
        domainDocsLocation = "http://localhost:8080/timegraph/MyDomain.source";

    // now initialize the text fields
    var txtFieldDomainName = new Ext.form.TextField({
    	fieldLabel: 'Domain Name',
    	name: 'domainName',
    	width:190
    });

    var txtFieldDomainDocsLocation = new Ext.form.TextField({
    	fieldLabel: 'Docs Location',
    	name: 'domainDocsLocation',
    	width:190
    });

    
    // set the initial values in the text fields
    txtFieldDomainName.setValue(domainName)
    txtFieldDomainDocsLocation.setValue(domainDocsLocation)

    // now create the form
	var simple = new Ext.form.FormPanel({
 
        standardSubmit: true,
 
        frame:true,
        title: 'Enter Domain Location',
 
        width: 350,
        defaults: {width: 230},
        defaultType: 'textfield',
		items: [
		    
		    txtFieldDomainName,
            txtFieldDomainDocsLocation,            
			{
                inputType: 'hidden',
                id: 'submitbutton',
                name: 'myhiddenbutton',
                value: 'hiddenvalue'
            }
 
        ],

        buttons: [{
            text: 'Submit',
            handler: function() {
                document.getElementById("domainlocationform").style.visibility = "hidden"
                document.getElementById("progressbar").style.visibility = "visible"

                //Ext.get("domainLocationForm").toggle()
                //Ext.get("progressbar").toggle()
                setCookie("domainName",txtFieldDomainName.getValue(), 365)
                setCookie("domainDocsLocation",txtFieldDomainDocsLocation.getValue(), 365)

		        simple.getForm().getEl().dom.action = 'RunDomainGenAction.groovy';
	            simple.getForm().getEl().dom.method = 'POST';
                simple.getForm().submit();
            }
        }]
  
    });

    // now render the form
    simple.render('domainlocationform');

});
